<div class="title">
  <h1><%=h @defender.name %></h1>
</div>
<div class="content">
  <div id="truppen">
    <% if nil != @defender.troops %>
      <h2>Truppen</h2>
      <table>
        <tr>
          <th />
          <th class="heading">Menge</th>
          <th class="heading">Angriff</th>
          <th class="heading">Verteidigung</th>
          <th class="heading">Leben</th>
        </tr>
        <% @defender.troops.each do |troop| %>
          <tr class="line">
            <td class="description"><%= link_to troop.unit.name, edit_defender_troop_path(@defender, troop) %></td>
            <td class="def" id="right"><%=h n troop.menge %></td>
            <td class="def" id="right"><%= n troop.angriff %></td>
            <td class="def" id="right"><%= n troop.verteidigung %></td>
            <td class="def" id="right"><%= n troop.leben %></td>
          </tr>
        <% end %>
        <tr id="summe">
          <td class="description">Summe</td>
          <td class="def" />
          <td class="def" id="right"><%= n @defender.sum_angriff %></td>
          <td class="def" id="right"><%= n @defender.sum_verteidigung %></td>
          <td class="def" id="right"><%= n @defender.sum_leben %></td>
        </tr>
      </table>
    <%  end %>
  </div>
  <div id="verluste">
    <% if nil != @defender.troops %>
      <h2>Verluste</h2>
      <table>
        <tr>
          <th />
          <th class="heading">Menge</th>
          <th class="heading">Essenzen</th>
          <th class="heading">Kristalle</th>
          <th class="heading">Kraftsteine</th>
          <th class="heading">Goldharz</th>
          <th class="heading">Punkte</th>
        </tr>
        <% @defender.troops.each do |troop| %>
          <% unless troop.losses == 0 %>
            <tr class="line">
              <td class="description"><%= link_to troop.unit.name, defender_troop_path(@defender, troop) %></td>
              <td class="def" id="right"><%=h n(troop.losses) %></td>
              <td class="def" id="right"><%=h n(troop.verluste_essenzen) %></td>
              <td class="def" id="right"><%=h n(troop.verluste_kristalle) %></td>
              <td class="def" id="right"><%=h n(troop.verluste_kraftsteine) %></td>
              <td class="def" id="right"><%=h n(troop.verluste_goldharz) %></td>
              <td class="def" id="right"><%=h n(troop.verluste_punkte) %></td>
            </tr>
          <% end %>
        <%  end %>
        <tr id="summe">
          <td class="description">Summe</td>
          <td class="def" />
          <td class="def" id="right"><%= n @defender.verluste_essenzen %></td>
          <td class="def" id="right"><%= n @defender.verluste_kristalle %></td>
          <td class="def" id="right"><%= n @defender.verluste_kraftsteine %></td>
          <td class="def" id="right"><%= n @defender.verluste_goldharz %></td>
          <td class="def" id="right"><%= n @defender.verluste_punkte %></td>
        </tr>
      </table>
    <% end %>
  </div>
</div>

<% content_for :navigation do %>
  <li>
    <%= link_to 'Bearbeiten', edit_attack_defender_path(@attack) %>
  </li>
  <li>
    <%= link_to 'Truppen', defender_troops_path(@defender) %>
  </li>
  <li>
    <%= link_to 'Armeen', attack_armies_path(@attack) %>
    <ul>
      <% @attack.armies.each do |army| %>
        <li>
          <%= link_to army, attack_army_path(@attack, army) %>
        </li>
      <% end %>
    </ul>
  </li>
  <li>
    <%= link_to 'Verteidiger', attack_defenders_path(@attack) %>
    <ul>
      <% @attack.defenders.each do |defender| %>
        <li>
          <%= link_to defender, attack_defender_path(@attack, defender) %>
        </li>
      <% end %>
    </ul>
  </li>
<% end %>